]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Convert remaining uses of "let me = this;" to Lang.bind
authorDan Winship <danw@gnome.org>
Tue, 15 Sep 2009 17:09:51 +0000 (13:09 -0400)
committerDan Winship <danw@gnome.org>
Tue, 15 Sep 2009 17:11:23 +0000 (13:11 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=595293

js/ui/appDisplay.js
js/ui/button.js
js/ui/docDisplay.js
js/ui/overview.js
js/ui/windowManager.js
js/ui/workspaces.js

index cf9966dabc7e0bd250dd7949e105b06a36c4d130..d40fdabdf12b0ead0d8e1ef7c8dfd885dbb90688 100644 (file)
@@ -358,7 +358,6 @@ AppDisplay.prototype = {
 
     // Gets information about all applications by calling Gio.app_info_get_all().
     _refreshCache : function() {
-        let me = this;
         if (!this._appsStale)
             return;
         this._allItems = {};
index 5fb594769d38d26087c7cdbbb0ffa7346250b3c3..443d77b3a07c004068c90a1f9bccde3a2e8d4db5 100644 (file)
@@ -28,8 +28,6 @@ function Button(widget, buttonColor, pressedButtonColor, textColor, font) {
 
 Button.prototype = {
     _init : function(widgetOrText, buttonColor, pressedButtonColor, textColor, font) {
-        let me = this;
-
         this._buttonColor = buttonColor
         if (buttonColor == null)
             this._buttonColor = DEFAULT_BUTTON_COLOR;
index 11f9039feffbe2f151a945c91a7e621ce0f81466..4410d4b528d48b7b6e85bd65d6386722b4347524 100644 (file)
@@ -120,8 +120,6 @@ DocDisplay.prototype = {
 
     _init : function() {
         GenericDisplay.GenericDisplay.prototype._init.call(this);
-        let me = this;
-
         // We keep a single timeout callback for updating last visited times
         // for all the items in the display. This avoids creating individual
         // callbacks for each item in the display. So proper time updates
@@ -132,14 +130,14 @@ DocDisplay.prototype = {
 
         this._docManager = DocInfo.getDocManager();
         this._docsStale = true;
-        this._docManager.connect('changed', function(mgr, userData) {
-            me._docsStale = true;
+        this._docManager.connect('changed', Lang.bind(this, function(mgr, userData) {
+            this._docsStale = true;
             // Changes in local recent files should not happen when we are in the Overview mode,
             // but redisplaying right away is cool when we use Zephyr.
             // Also, we might be displaying remote documents, like Google Docs, in the future
             // which might be edited by someone else.
-            me._redisplay(false);
-        });
+            this._redisplay(false);
+        }));
 
         this.connect('destroy', Lang.bind(this, function (o) {
             if (this._updateTimeoutId > 0)
index 7afc56424b7521ce5dc72494dc93b42f981ee18b..cab7d5956a8077211a0d8e848b58aed2f7799c04 100644 (file)
@@ -81,8 +81,6 @@ function Overview() {
 
 Overview.prototype = {
     _init : function() {
-        let me = this;
-
         this._group = new Clutter.Group();
         this._group._delegate = this;
 
index 73303db5d94e339538224724abd0083e7ad1fdfa..2ebe5fcbcabadf7e264f4dcd8a56ba5049c39521 100644 (file)
@@ -1,6 +1,7 @@
 /* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
 const Clutter = imports.gi.Clutter;
+const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Meta = imports.gi.Meta;
 
@@ -16,9 +17,8 @@ function WindowManager() {
 
 WindowManager.prototype = {
     _init : function() {
-        let me = this;
+        let shellwm = global.window_manager;
 
-        this._shellwm = global.window_manager;
         this._minimizing = [];
         this._maximizing = [];
         this._unmaximizing = [];
@@ -26,60 +26,20 @@ WindowManager.prototype = {
         this._destroying = [];
 
         this._switchData = null;
-        this._shellwm.connect('switch-workspace',
-            function(o, from, to, direction) {
-                let actors = me._shellwm.get_switch_workspace_actors();
-                me._switchWorkspace(actors, from, to, direction);
-            });
-        this._shellwm.connect('kill-switch-workspace',
-            function(o) {
-                me._switchWorkspaceDone();
-            });
-        this._shellwm.connect('minimize',
-            function(o, actor) {
-                me._minimizeWindow(actor);
-            });
-        this._shellwm.connect('kill-minimize',
-            function(o, actor) {
-                me._minimizeWindowDone(actor);
-            });
-        this._shellwm.connect('maximize',
-            function(o, actor, tx, ty, tw, th) {
-                me._maximizeWindow(actor, tx, ty, tw, th);
-            });
-        this._shellwm.connect('kill-maximize',
-            function(o, actor) {
-                me._maximizeWindowDone(actor);
-            });
-        this._shellwm.connect('unmaximize',
-            function(o, actor, tx, ty, tw, th) {
-                me._unmaximizeWindow(actor, tx, ty, tw, th);
-            });
-        this._shellwm.connect('kill-unmaximize',
-            function(o, actor) {
-                me._unmaximizeWindowDone(actor);
-            });
-        this._shellwm.connect('map',
-            function(o, actor) {
-                me._mapWindow(actor);
-            });
-        this._shellwm.connect('kill-map',
-            function(o, actor) {
-                me._mapWindowDone(actor);
-            });
-        this._shellwm.connect('destroy',
-            function(o, actor) {
-                me._destroyWindow(actor);
-            });
-        this._shellwm.connect('kill-destroy',
-            function(o, actor) {
-                me._destroyWindowDone(actor);
-            });
-
-        this._shellwm.connect('begin-alt-tab',
-            function(o, handler) {
-                me._beginAltTab(handler);
-            });
+        shellwm.connect('switch-workspace', Lang.bind(this, this._switchWorkspace));
+        shellwm.connect('kill-switch-workspace', Lang.bind(this, this._switchWorkspaceDone));
+        shellwm.connect('minimize', Lang.bind(this, this._minimizeWindow));
+        shellwm.connect('kill-minimize', Lang.bind(this, this._minimizeWindowDone));
+        shellwm.connect('maximize', Lang.bind(this, this._maximizeWindow));
+        shellwm.connect('kill-maximize', Lang.bind(this, this._maximizeWindowDone));
+        shellwm.connect('unmaximize', Lang.bind(this, this._unmaximizeWindow));
+        shellwm.connect('kill-unmaximize', Lang.bind(this, this._unmaximizeWindowDone));
+        shellwm.connect('map', Lang.bind(this, this._mapWindow));
+        shellwm.connect('kill-map', Lang.bind(this, this._mapWindowDone));
+        shellwm.connect('destroy', Lang.bind(this, this._destroyWindow));
+        shellwm.connect('kill-destroy', Lang.bind(this, this._destroyWindowDone));
+
+        shellwm.connect('begin-alt-tab', Lang.bind(this, this._beginAltTab));
     },
 
     _shouldAnimate : function(actor) {
@@ -99,9 +59,9 @@ WindowManager.prototype = {
         return false;
     },
 
-    _minimizeWindow : function(actor) {
+    _minimizeWindow : function(shellwm, actor) {
         if (!this._shouldAnimate(actor)) {
-            this._shellwm.completed_minimize(actor);
+            shellwm.completed_minimize(actor);
             return;
         }
 
@@ -119,49 +79,49 @@ WindowManager.prototype = {
                            transition: "easeOutQuad",
                            onComplete: this._minimizeWindowDone,
                            onCompleteScope: this,
-                           onCompleteParams: [actor],
+                           onCompleteParams: [shellwm, actor],
                            onOverwrite: this._minimizeWindowOverwritten,
                            onOverwriteScope: this,
-                           onOverwriteParams: [actor]
+                           onOverwriteParams: [shellwm, actor]
                          });
     },
 
-    _minimizeWindowDone : function(actor) {
+    _minimizeWindowDone : function(shellwm, actor) {
         if (this._removeEffect(this._minimizing, actor)) {
             Tweener.removeTweens(actor);
             actor.set_scale(1.0, 1.0);
             actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
 
-            this._shellwm.completed_minimize(actor);
+            shellwm.completed_minimize(actor);
         }
     },
 
-    _minimizeWindowOverwritten : function(actor) {
+    _minimizeWindowOverwritten : function(shellwm, actor) {
         if (this._removeEffect(this._minimizing, actor)) {
-            this._shellwm.completed_minimize(actor);
+            shellwm.completed_minimize(actor);
         }
     },
 
-    _maximizeWindow : function(actor, targetX, targetY, targetWidth, targetHeight) {
-        this._shellwm.completed_maximize(actor);
+    _maximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
+        shellwm.completed_maximize(actor);
     },
 
-    _maximizeWindowDone : function(actor) {
+    _maximizeWindowDone : function(shellwm, actor) {
     },
 
-    _maximizeWindowOverwrite : function(actor) {
+    _maximizeWindowOverwrite : function(shellwm, actor) {
     },
 
-    _unmaximizeWindow : function(actor, targetX, targetY, targetWidth, targetHeight) {
-        this._shellwm.completed_unmaximize(actor);
+    _unmaximizeWindow : function(shellwm, actor, targetX, targetY, targetWidth, targetHeight) {
+        shellwm.completed_unmaximize(actor);
     },
 
-    _unmaximizeWindowDone : function(actor) {
+    _unmaximizeWindowDone : function(shellwm, actor) {
     },
 
-    _mapWindow : function(actor) {
+    _mapWindow : function(shellwm, actor) {
         if (!this._shouldAnimate(actor)) {
-            this._shellwm.completed_map(actor);
+            shellwm.completed_map(actor);
             return;
         }
 
@@ -178,31 +138,31 @@ WindowManager.prototype = {
                            transition: "easeOutQuad",
                            onComplete: this._mapWindowDone,
                            onCompleteScope: this,
-                           onCompleteParams: [actor],
+                           onCompleteParams: [shellwm, actor],
                            onOverwrite: this._mapWindowOverwrite,
                            onOverwriteScope: this,
-                           onOverwriteParams: [actor]
+                           onOverwriteParams: [shellwm, actor]
                          });
     },
 
-    _mapWindowDone : function(actor) {
+    _mapWindowDone : function(shellwm, actor) {
         if (this._removeEffect(this._mapping, actor)) {
             Tweener.removeTweens(actor);
             actor.set_scale(1.0, 1.0);
             actor.move_anchor_point_from_gravity(Clutter.Gravity.NORTH_WEST);
-            this._shellwm.completed_map(actor);
+            shellwm.completed_map(actor);
         }
     },
 
-    _mapWindowOverwrite : function(actor) {
+    _mapWindowOverwrite : function(shellwm, actor) {
         if (this._removeEffect(this._mapping, actor)) {
-            this._shellwm.completed_map(actor);
+            shellwm.completed_map(actor);
         }
     },
 
-    _destroyWindow : function(actor) {
+    _destroyWindow : function(shellwm, actor) {
         if (!this._shouldAnimate(actor)) {
-            this._shellwm.completed_destroy(actor);
+            shellwm.completed_destroy(actor);
             return;
         }
 
@@ -217,33 +177,35 @@ WindowManager.prototype = {
                            transition: "easeOutQuad",
                            onComplete: this._destroyWindowDone,
                            onCompleteScope: this,
-                           onCompleteParams: [actor],
+                           onCompleteParams: [shellwm, actor],
                            onOverwrite: this._destroyWindowOverwrite,
                            onOverwriteScope: this,
-                           onOverwriteParams: [actor]
+                           onOverwriteParams: [shellwm, actor]
                          });
     },
     
-    _destroyWindowDone : function(actor) {
+    _destroyWindowDone : function(shellwm, actor) {
         if (this._removeEffect(this._destroying, actor)) {
-            this._shellwm.completed_destroy(actor);
+            shellwm.completed_destroy(actor);
             Tweener.removeTweens(actor);
             actor.set_scale(1.0, 1.0);
         }
     },
 
-    _destroyWindowOverwrite : function(actor) {
+    _destroyWindowOverwrite : function(shellwm, actor) {
         if (this._removeEffect(this._destroying, actor)) {
-            this._shellwm.completed_destroy(actor);
+            shellwm.completed_destroy(actor);
         }
     },
 
-    _switchWorkspace : function(windows, from, to, direction) {
+    _switchWorkspace : function(shellwm, from, to, direction) {
         if (!this._shouldAnimate()) {
-            this._shellwm.completed_switch_workspace();
+            shellwm.completed_switch_workspace();
             return;
         }
 
+        let windows = shellwm.get_switch_workspace_actors();
+
         /* @direction is the direction that the "camera" moves, so the
          * screen contents have to move one screen's worth in the
          * opposite direction.
@@ -305,7 +267,8 @@ WindowManager.prototype = {
                            time: WINDOW_ANIMATION_TIME,
                            transition: "easeOutQuad",
                            onComplete: this._switchWorkspaceDone,
-                           onCompleteScope: this
+                           onCompleteScope: this,
+                           onCompleteParams: [shellwm]
                          });
         Tweener.addTween(switchData.inGroup,
                          { x: 0,
@@ -315,7 +278,7 @@ WindowManager.prototype = {
                          });
     },
 
-    _switchWorkspaceDone : function() {
+    _switchWorkspaceDone : function(shellwm) {
         let switchData = this._switchData;
         if (!switchData)
             return;
@@ -334,10 +297,10 @@ WindowManager.prototype = {
         switchData.inGroup.destroy();
         switchData.outGroup.destroy();
 
-        this._shellwm.completed_switch_workspace();
+        shellwm.completed_switch_workspace();
     },
 
-    _beginAltTab : function(handler) {
+    _beginAltTab : function(shellwm, handler) {
         let popup = new AltTab.AltTabPopup();
 
         handler.connect('window-added', function(handler, window) { popup.addWindow(window); });
index 12e4b77d42ae9c687a2e120a341058b91fee3cd0..de9e60f247371c89215dcbb7e5fb3db912bb9e3c 100644 (file)
@@ -416,8 +416,6 @@ function Workspace(workspaceNum, parentActor) {
 
 Workspace.prototype = {
     _init : function(workspaceNum, parentActor) {
-        let me = this;
-
         this.workspaceNum = workspaceNum;
         this._metaWorkspace = global.screen.get_workspace_by_index(workspaceNum);